import { MessageType } from '@/constants/chat';
import { IChunk } from './knowledge';
import { Key } from 'react';

export interface PromptConfig {
  emptyResponse: string;
  parameters: Parameter[];
  prologue: string;
  system: string;
}

export interface Parameter {
  key: string;
  optional: boolean;
}

export interface LlmSetting {
  Creative: Variable;
  Custom: Variable;
  Evenly: Variable;
  Precise: Variable;
}

export interface Variable {
  frequencyPenalty?: number;
  maxTokens?: number;
  presencePenalty?: number;
  temperature?: number;
  topP?: number;
}

export interface IDialog {
  appId: string;
  createAt: string;
  createBy: number;
  description: string;
  icon: string;
  datasetIds: string[];
  datasetNames: string[];
  language: string;
  modelId: string;
  modelConfig: Variable;
  // llm_setting_type: string;
  name: string;
  promptConfig: PromptConfig;
  prompt_type: string;
  status: string;
  updateAt: string;
  updateBy: number;
  vectorSimilarityWeight: number;
  similarityThreshold: number;
}

export interface IConversation {
  appId: Key | null | undefined;
  createDate: string;
  createTime: number;
  conversationId: string;
  message: Message[];
  reference: IReference[];
  name: string;
  updateDate: string;
  updateTime: number;
}

export interface Message {
  content: string;
  role: MessageType;
  documentIds?: string[];
  prompt?: string;
  id?: string;
  audioBinary?: string;
}

export interface IReference {
  chunks: IChunk[];
  docAggs: Docagg[];
  total: number;
}

export interface IAnswer {
  answer: string;
  reference: IReference;
  conversationId?: string;
  prompt?: string;
  id?: string;
  audioBinary?: string;
}

export interface Docagg {
  count: number;
  docId: string;
  docName: string;
}

// interface Chunk {
//   chunk_id: string;
//   content_ltks: string;
//   content_with_weight: string;
//   doc_id: string;
//   docnm_kwd: string;
//   img_id: string;
//   important_kwd: any[];
//   datasetId: string;
//   similarity: number;
//   term_similarity: number;
//   vector_similarity: number;
// }

export interface IToken {
  createDate: string;
  createTime: number;
  orgId: string;
  token: string;
  updateDate?: any;
  updateTime?: any;
}

export interface IStats {
  pv: [string, number][];
  uv: [string, number][];
  speed: [string, number][];
  tokens: [string, number][];
  round: [string, number][];
  thumbUp: [string, number][];
}
